//
//  FunctionConfig.h
//  v2ex-shelves
//
//  Created by Mac os on 2018/4/8.
//  Copyright © 2018年 Mac os. All rights reserved.
//

#ifndef FunctionConfig_h
#define FunctionConfig_h

#ifdef DEBUG
#define WTString [NSString stringWithFormat:@"%s", __FILE__].lastPathComponent
#define WTLog(...) printf("%s 第%d行: %s\n\n",[WTString UTF8String] ,__LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String]);

#else

#define WTLog(...)

#endif



#define IOS9 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
#define FONT_MEDIUM    (IOS9?@"PingFangSC-Medium":@"Helvetica")  //苹方中黑
#define FONT_REGULAR   (IOS9?@"PingFangSC-Regular":@"Helvetica")  // 苹方常规
#define FONT_SEMIBOLD   (IOS9?@"PingFangSC-Semibold":@"Helvetica")  //苹方中粗
#define SINGLE_LINE_WIDTH   (1 / [UIScreen mainScreen].scale) //绘制一个像素的宽度


#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define WTColor(r, g, b) [UIColor colorWithRed: (r)/255.0 green: (g)/255.0 blue: (b)/255.0 alpha: 1.0]

#define tabbarHeight 49
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define WTScreenWidth [UIScreen mainScreen].bounds.size.width
#define WTScreenHeight [UIScreen mainScreen].bounds.size.height
#define SCALEPhoneHEIGHT [UIScreen mainScreen].bounds.size.height/667
#define SCALEPhoneWIDTH  [UIScreen mainScreen].bounds.size.width/375

#pragma mark - IPHONEX
#define IPHONEX_HEIGHT 812
#define IPHONEX_WIDTH  375
#define STATUSBARHEIGHT    (isIPHONEX ?  40 : 20)
#define NavigationBarHeight (isIPHONEX ?  84 : 64)
#define WTNavigationBarCenterY (ISIPHONEX ? 20 : 10)
#define WTNavigationBarMaxY (ISIPHONEX  ? 84 : 64)


#define isIPHONEX ([UIScreen mainScreen].bounds.size.height == IPHONEX_HEIGHT && [UIScreen mainScreen].bounds.size.width == IPHONEX_WIDTH)


#pragma mark - SafeArea

static inline CGFloat TLSafeAreaInsetsTop() {
    if (@available(iOS 11.0, *)) {
        return UIApplication.sharedApplication.delegate.window.safeAreaInsets.top;
    } else {
        return 0;
    }
}

static inline CGFloat TLSafeAreaInsetsBottom() {
    if (@available(iOS 11.0, *)) {
        return UIApplication.sharedApplication.delegate.window.safeAreaInsets.bottom;
    } else {
        return 0;
    }
}

#define SafeAreaInsetsTop TLSafeAreaInsetsTop()
#define SafeAreaInsetsBottom TLSafeAreaInsetsBottom()
#define SafeAreaInsetsHeight TLSafeAreaInsetsTop() + TLSafeAreaInsetsBottom()

#pragma mark 自定义导航高度
#define NavigationBarCustomHeight(navController) (navController ? (navController.navigationBar.frame.size.height + UIApplication.sharedApplication.statusBarFrame.size.height) : 0)


#endif /* FunctionConfig_h */
